package com.xrz.sxm.aj.utils;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.DisplayMetrics;

public class ScreenUtil {

	private static ScreenUtil su;
	public static ScreenUtil getInstant(){
		if(su == null) su = new ScreenUtil();
		return su;
	}
	
	public void init(Activity a){
		DisplayMetrics dm = new DisplayMetrics();
		a.getWindowManager().getDefaultDisplay().getMetrics(dm);
		int disWidth = dm.widthPixels;
		int disHight = dm.heightPixels;
		putScreen(a, disWidth, disHight);
	}
	
	private SharedPreferences getPreferences(Context c){
		return c.getSharedPreferences("screenInfo", 1);
	}
	
	private void putScreen(Context c, int width, int hight){
		getPreferences(c).edit().putInt("width", width).putInt("hight", hight).commit();
	}
	
	public int getDisWidth(Context c){
		return getPreferences(c).getInt("width", 0);
	}
	
	public int getDisHight(Context c){
		return getPreferences(c).getInt("hight", 0); 
	}
	
	public void putViewScreen(Context c,int width,int height){
		getPreferences(c).edit().putInt("Tabwidth",width).putInt("Tabheight",height).commit();
	}
	
	public void putTopViewScreen(Context c,int width,int height){
		getPreferences(c).edit().putInt("Topwidth",width).putInt("Topheight",height).commit();
	}
	
	public int getTabHeight(Context c){
		return getPreferences(c).getInt("Tabheight", 0);
	}
	
	public  int  getTopViewHeight(Context c){
		return getPreferences(c).getInt("Topheight", 0);
	}
}
